import os
import pickle
path = os.path.join(THIS.root_dir, 'translations.pkl')
encoding = 'utf-8'
with open(path, 'rb') as f:
    translations = pickle.load(f)

def translate(src):
    if src not in translations:
        return src
    langs = REQUEST_HEADERS.get('Accept-language').split(',')
    for lang in langs:
        lang = lang.split(';')[0]
        lang = lang.split('-')[0]
        try:
            return translations[src][lang]
        except KeyError:
            continue
    try:
        return translations[src]['default']
    except KeyError:
        return src
